#include "print_buffer.h"

Print_Buffer :: Print_Buffer () {
	// Variables for the block method
	space_length = 2;
	box_thickness = 2;
	space_type = ' ';
	box_border_type = '/';
	verb = ALL;
}

Print_Buffer :: ~Print_Buffer () {

}

void Print_Buffer :: block (string text) {

	int text_length = text.size ();
	int box_length = text_length + (2 * space_length) + (2 * box_thickness);

	char box_border [box_length + 1];
	char box_text [box_length + 1];
	int index = 0;

	memset (box_border, '\0', box_length + 1);
	memset (box_text, '\0', box_length + 1);

	/* Build the box border */
	for (int i = 0; i < box_length; i++) {
		box_border [i] = box_border_type;
	}

	/* Build the center of the box */
	// The first box thickness
	for (int i = 0; i < box_thickness; i++) {
		box_text [index] = box_border_type;
		index++;
	}

	// The first whitespace
	for (int i = 0; i < space_length; i++) {
		box_text [index] = space_type;
		index++;
	}

	// The text itself
	for (int i = 0; i < text_length; i++) {
		box_text [index] = text [i];
		index++;
	}

	// The whitespace after
	for (int i = 0; i < space_length; i++) {
		box_text [index] = space_type;
		index++;
	}
	
	// The box thickness after
	for (int i = 0; i < box_thickness; i++) {
		box_text [index] = box_border_type;
		index++;
	}

	/* Finally print it out */
	cout << endl;
	cout << box_border << endl;
	cout << box_text << endl;
	cout << box_border << endl;
	cout << endl;
}

// TODO
void Print_Buffer :: out (string text) {
	
}

string Print_Buffer :: get_verbosity () {
	string result = "";

	if (verb == ALL) {
		result = "ALL";
	} else if (verb == NONE) {
		result = "NONE";
	} else {
		result = "error";
	}

	return result;
}

